package com.xiami.controller;

import com.xiami.pojo.Emp;
import com.xiami.pojo.MyResponseResult;
import com.xiami.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/*
创建者:虾米糖
*/
@Slf4j
@RestController
public class LoginController {
    @Autowired
    private EmpService empService;

    @PostMapping("/login")
    public MyResponseResult login(@RequestBody Emp emp) {
        log.info("员工登录:{}", emp);
       Emp e = empService.login(emp);
        return e !=null? MyResponseResult.ok(e):MyResponseResult.error("用户名或密码错误");
    }

}
